package com.perfma.xtest.tool;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.Data;

import java.util.List;

/**
 * @author: junhui.si
 * @date: 2021-12-01 14:06
 **/
public class FastJsonTest {
    public static void main(String[] args) {
//        for (int j = 0; j < 10; j++) {
//            List<User> list = Lists.newArrayList();
//            for (int i = 0; i < 200000; i++) {
//                list.add(User.builder()
//                        .a1("sadasadassadasdasdsadasdasdsadasdasdsadasdasdsadasdasdsadasdasdsadasdasdsadasdasdsadasdasddasdsdasd" + i)
//                        .a2("xcwsadasadassadasdasdsadasdasdsadasdasdsadasdasdsadasdasdsadasdasdsadasdasdsadasdasdsadasdasddasdsdasdedwe" + i)
//                        .a3("234234sadasadassadasdasdsadasdasdsadasdasdsadasdasdsadasdasdsadasdasdsadasdasdsadasdasdsadasdasddasdsdasd234" + i)
//                        .build());
//            }
//            long time = System.currentTimeMillis();
//            String s = JSON.toJSONString(list);
//            System.out.println("size:" + s.getBytes().length / 1024 / 1024);
//            System.out.println("cost:" + (System.currentTimeMillis() - time));
//            System.out.println("####################");
//        }
        String s = "{\"orgId\":1,\"envId\":1,\"labelUpdateList\":[],\"insertList\":[],\"deleteList\":[{\"ip\":\"10.10.10.1\",\"port\":9103,\"exporterType\":\"MYSQL\"}]}";
        PrometheusExporterUpdateDto aa = new PrometheusExporterUpdateDto();
        aa.setEnvId(1L);
        aa.setOrgId(1L);
        aa.setLabelUpdateList(Lists.newArrayList());
        aa.setInsertList(Lists.newArrayList());
        aa.setDeleteList(Lists.newArrayList(PrometheusExporterDto.builder().ip("10.10.10.1").port(9103).exporterType("MYSQL").build()));

        PrometheusExporterUpdateDto data = JSON.parseObject(JSON.toJSONString(aa), PrometheusExporterUpdateDto.class);
        System.out.println(data);
    }
}

@Data
@Builder
class User {
    private String a1;
    private String a2;
    private String a3;
}
